<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\api\model\store\shop;

use app\common\model\store\shop\Diy as DiyModel;

/**
 * 商家门店店员模型
 * Class Clerk
 * @package app\api\model\store\shop
 */
class Diy extends DiyModel {
	/**
	 * 隐藏字段
	 * @var array
	 */
	protected $hidden = [
		'is_delete',
		'store_id',
		'create_time',
		'update_time',
	];

	public static function increased(int $shop_id, array $contentList) {

		foreach ($contentList as $content) {
			$data['image_id'] = $content['uploaded'];
			$data['content'] = $content['content'];
			$data['shop_id'] = $shop_id;
			$data['create_time'] = time();
			$data['store_id'] = self::$storeId;

			$insertData[] = $data;
		}
		return (new static )->addAll($insertData);

	}

		public function getList(int $shopId) {
		// 查询构造器
		$query = $this->getNewQuery();

		// 获取门店列表数据
		$list = $query->with(['image'])
			->where('shop_id', '=', $shopId)
			->order(['id' => 'asc'])
			->select();

		return $list;
	}
}